//
//  ImageToSoundViewController.m
//  ImageToSound
//
//  Created by jvmilazz on 9/26/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "ImageToSoundViewController.h"

@implementation ImageToSoundViewController

@synthesize selectedImage;

- (void)dealloc
{
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
    [super viewDidLoad];
}
*/

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

-(IBAction) buttonClicked {
    
    picker = [[UIImagePickerController alloc] init];
    
    picker.delegate = self;
    
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
        
    {
        
        picker.sourceType = UIImagePickerControllerSourceTypeCamera;
        
    } else
        
    {
        
        picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
        
    }
    
    [self presentModalViewController:picker animated:YES];
    
}


- (void)imagePickerControllerDidCancel:(UIImagePickerController *) Picker {
    
    [[Picker parentViewController] dismissModalViewControllerAnimated:YES];
    
    [Picker release];
    
}


- (void)imagePickerController:(UIImagePickerController *) Picker

didFinishPickingMediaWithInfo:(NSDictionary *)info {
    
    selectedImage.image = [info objectForKey:UIImagePickerControllerOriginalImage];
    
    [[Picker parentViewController] dismissModalViewControllerAnimated:YES];
    
    [Picker release];
    
}


/* Replaced with buttonClicked_play
 -(IBAction)buttonTouch_createSound
{
    UIAlertView *objalert = [[UIAlertView alloc]initWithTitle:@"Alert box demo" message:@"This has not been implemented." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:@"Cancel",nil];
    [objalert show];
}*/

-(IBAction)buttonClicked_createSound
{
    createSoundVC = [[CreateSoundViewController alloc] initWithNibName:@"CreateSoundViewController" bundle:[NSBundle mainBundle]];
    [createSoundVC.view setFrame:[[UIScreen mainScreen] applicationFrame]];
    [self.view addSubview:createSoundVC.view];
    // Load a new view.
}

- (IBAction) buttonClicked_play
{
    UIAlertView *objalert = [[UIAlertView alloc]initWithTitle:@"Attention" message:@"The phone just vibrated." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:@"Cancel",nil];
    [objalert show];
}



@end
